#ifndef SERVER_H
#define SERVER_H

#include <QWidget>
#include <QTcpServer>
#include <QTcpSocket>
#include <QTableWidget>
#include <QString>
#include <QList>

QT_BEGIN_NAMESPACE
namespace Ui { class server; }
QT_END_NAMESPACE

struct ClientInfo {
    QString username;
    QTcpSocket* clientSocket;
};

class server : public QWidget
{
    Q_OBJECT

public:
    server(QWidget *parent = nullptr);
    ~server();

private slots:
    void newConnection();
    void onReadyRead(QTcpSocket *clientSocket);
    void sendResponse(QTcpSocket *clientSocket, const QString &responseType);

private:
    Ui::server *ui;
    QTcpServer *server1;
    QTableWidget *tableWidget;
    QList<ClientInfo> clients;
};
#endif // SERVER_H
